﻿<cfsilent>
	<cfscript>
		
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		response = structNew();
		
		transaction {
			
			/* 更新行政班 教学计划属性 */
			sql = "SELECT cidx 
					FROM t_plan 
					WHERE p_id = :pId " ;
			queryObj = new query( datasource=application.dnsMaster );
			queryObj.addParam( name="pId", value=event.getArg("PID"), cfsqltype="cf_sql_varchar" );
			rs_classPlan = queryObj.execute( sql=sql ).getResult();
			
			courseIndex = rs_classPlan.cidx;
			
			switch ( event.getArg('prop') ) {
				
				/* 修改班级排课课序号 */
				case "ForCourse":
					
					if ( yesNoFormat(event.getArg('status')) ) {
						if ( courseIndex eq "XXX" ) {
							courseIndex = "000";
						}
					}
					else {
						courseIndex = "XXX";
					}
					
					break;
				
			}
			sql = "UPDATE t_plan 
					SET cidx = :courseIndex  
					WHERE p_id = :pId " ;
			queryObj = new query( datasource=application.dnsMaster );
			queryObj.addParam( name="courseIndex", value=courseIndex, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="pId", value=event.getArg("PID"), cfsqltype="cf_sql_varchar" );
			queryObj.execute( sql=sql );

			structInsert(response, "PlanID", event.getArg("PID"));
			structInsert(response, "CourseIndex", courseIndex);
			
		}
		
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>